<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */


/**
 * Smarty {NotSpam} function plugin
 *
 * Type:     function<br>
 * Name:     NotSpam<br>
 * Date:     November 10, 2006<br>
 * Purpose:  make standart vizualization of File size.
 * Input:<br>
 *           - email     (required) - e-mail string
 			 - link      (required) - Link to not_spam.php
 			 - title     (optional) - Title for link, default 'e-mail'
 			 - variable  (optional) - variable name for email string, default "em"
 			 - repalacer (optional) - variable for which will be replaced @, default "*cat*"
 			 - target    (optional) - target NULL frame, default "mail"
 			 - extra     (optional) - for decoration of link: class=...
 * Examples:
 * <pre>
 * {notspam email=$email link="/lib/not_spam.php"}
 * {notspam email=$email link="/lib/not_spam.php" variable="em"}
 * </pre>
 * @author   Novachok A. <novachok at ukr dot net>
 * @version  1.0
 * @param array
 * @param Smarty
 */
function smarty_function_notspam($params, &$smarty)
{
    $email = null;
    $link = null;
    $variable = null;
    $replacer = null;
    $target = null;
    $title = null;
    $extra = '';

    foreach($params as $_key => $_val)
    {
    	$$_key = $_val;
    }

    if($variable == false || $variable == null) $variable = 'em';
    if($replacer == false || $replacer == null) $replacer = '*cat*';
    if($target == false || $target == null) $target = 'mail';
    if($title == false || $title == null) $title = 'e-mail';

    $value = "<a href='" . $link . "?" . $variable . "=";
    $value = $value . preg_replace("/@/", $replacer, $email);
    $value .= "' target='" . $target . "' " . $extra . ">";
    $value .= $title . "</a>";

    return $value;
}
?>